﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DatabaseCompare.Model
{


    /// <summary>
    /// 比较结果.
    /// </summary>
    public enum CommonCompareResult
    {
        /// <summary>
        /// 完全相同
        /// </summary>
        FullSame = 0,


        /// <summary>
        /// 左边的没有了.
        /// 右边的有
        /// </summary>
        LeftIsMissing = 1,


        /// <summary>
        /// 左边的有了.
        /// 右边的没有了,
        /// </summary>
        RightIsMissing = 2,


        /// <summary>
        /// 左边右边都没有.
        /// 为避免外部错误的调用
        /// 设置这种结果.
        /// </summary>
        BothIsMissing = 3,


        /// <summary>
        /// 不匹配.
        /// </summary>
        Difference = 256,

    }





    public interface ICompareAbleResult
    {
        /// <summary>
        /// 基本的比较结果.
        /// </summary>
        CommonCompareResult CompareResult { set; get; }
    }




    public abstract class CompareAbleResult<T> : ICompareAbleResult
        where T : CompareAble
    {

        /// <summary>
        /// 左边的
        /// </summary>
        public T Left { set; get; }

        /// <summary>
        /// 右边的
        /// </summary>
        public T Right { set; get; }


        /// <summary>
        /// 基本的比较结果.
        /// </summary>
        public CommonCompareResult CompareResult { set; get; }


        /// <summary>
        /// 备注/说明信息不同.
        /// </summary>
        public bool CommentDifference { set; get; }


        /// <summary>
        /// 取得抽象的不匹配信息.
        /// </summary>
        /// <returns></returns>
        public abstract string GetDifferenceString();


        public override string ToString()
        {
            if (CompareResult == CommonCompareResult.BothIsMissing)
            {
                return "左右都为空";
            }
            else if (CompareResult == CommonCompareResult.FullSame)
            {
                return "完全匹配";
            }
            else if (CompareResult == CommonCompareResult.LeftIsMissing)
            {
                return "左边没有";
            }
            else if (CompareResult == CommonCompareResult.RightIsMissing)
            {
                return "右边没有";
            }
            else
            {
                return GetDifferenceString() ;
            }
        }
    }


}
